package pers.aidenj.ostrich.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import pers.aidenj.ostrich.common.DataSource.DynamicDataSourceHolder;
import pers.aidenj.ostrich.common.annotation.DataSource;
import pers.aidenj.ostrich.mapper.DictionaryMapper;
import pers.aidenj.ostrich.model.Dictionary;
import pers.aidenj.ostrich.service.DictionaryService;

@Service("dictionaryService")
public class DictionaryServiceImpl implements DictionaryService {

	@Resource
	DictionaryMapper dictionaryMapper;
	
	@Override
	public boolean getOneData() {
		// TODO Auto-generated method stub
		return true;
	}

	//没有指定库，使用默认
	@Override
	public List<Dictionary> getAllDictionary() {
		// TODO Auto-generated method stub
		return dictionaryMapper.getAllDictionary();
	}

	//指定master
	@Override
	@DataSource("datasource")
	public List<Dictionary> getAllDictionaryMasterDataSource() {
		// TODO Auto-generated method stub
		return dictionaryMapper.getAllDictionary();
	}

	//指定master
	@Override
	public List<Dictionary> getAllDictionaryMaster() {
		// TODO Auto-generated method stub
		DynamicDataSourceHolder.setDataSource("datasource");
		return dictionaryMapper.getAllDictionary();
	}
	
	//指定slave
	@Override
	@DataSource("datasource1")
	public List<Dictionary> getAllDictionarySlaveDataSource() {
		// TODO Auto-generated method stub
		return dictionaryMapper.getAllDictionary();
	}
	//指定slave
	@Override
	public List<Dictionary> getAllDictionarySlave() {
		// TODO Auto-generated method stub
		DynamicDataSourceHolder.setDataSource("datasource1");
		return dictionaryMapper.getAllDictionary();
	}


}
